<template>
	<view>
		<block v-for="(item,index) in diyItems" :key="index">

			<!--搜索框-->
		<!-- 	<template v-if="item.type==='search'">
				<search :itemData="item"></search>
			</template> -->

			<!--轮播图-->
			<template v-if="item.type==='banner'&&item.data!=null">
				<banner :itemData="item"></banner>
			</template>

			<!--单组图-->
			<template v-if="item.type==='imageSingle'&&item.data!=null">
				<imagesingle :itemData="item"></imagesingle>
			</template>

			<!-- 橱窗-->
			<template v-if="item.type == 'window'&&item.data!=null">
				<windows :itemData="item"></windows>
			</template>

			<!-- 视频组-->
			<template v-if="item.type == 'video'">
				<videos :itemData="item"></videos>
			</template>

			<!--文章-->
			<template v-if="item.type == 'article'&&item.data!=null">
				<articles :itemData="item"></articles>
			</template>

			<!--头条快报-->
			<template v-if="item.type == 'special'&&item.data!=null">
				<special :itemData="item"></special>
			</template>

			<!--公告组-->
			<template v-if="item.type == 'notice'">
				<notice :itemData="item"></notice>
			</template>

			<!--标题组-->
			<!-- 接口中返回多余的title配置 -->
			<!-- <template v-if="item.type == 'title'">
				<titles :itemData="item"></titles>
			</template> -->

			<!--导航组-->
			<template v-if="item.type==='navBar'&&item.data!=null">
				<navBar :itemData="item"></navBar>
			</template>

			<!--商品组-->
			<template v-if="item.type==='product'&&item.data!=null">
				<product :itemData="item" :state="state"></product>

			</template>

			<!--优惠券-->
			<template v-if="item.type==='coupon'&&item.data!=null">
				<coupon :itemData="item"></coupon>
			</template>

			<!--门店-->
			<template v-if="item.type == 'store'&&item.data!=null">
				<store :itemData="item"></store>
			</template>

			<!--客服-->
			<template v-if="item.type == 'service'">
				<service :itemData="item"></service>
			</template>

			<!--富文本-->
			<template v-if="item.type==='richText'">
				<richText :itemData="item"></richText>
			</template>

			<!--辅助空白-->
			<template v-if="item.type == 'blank'">
				<blank :itemData="item"></blank>
			</template>
			<!--辅助线-->
			<template v-if="item.type == 'guide'">
				<guide :itemData="item"></guide>
			</template>

			<!--秒杀-->
			<template v-if="item.type == 'seckillProduct'&&item.data!=null">
				<seckillProduct :itemData="item"></seckillProduct>
			</template>

			<!--拼团-->
			<template v-if="item.type == 'assembleProduct'&&item.data!=null">
				<assembleProduct :itemData="item"></assembleProduct>
			</template>

			<!--砍价-->
			<template v-if="item.type == 'bargainProduct'&&item.data!=null">
				<bargainProduct :itemData="item"></bargainProduct>
			</template>

			<!--直播-->
			<template v-if="item.type == 'live'&&item.data!=null">
				<live :itemData="item"></live>
			</template>

		</block>
	</view>
</template>

<script>
	//import search from './search/search';
	import banner from './banner/banner';
	import imagesingle from './imagesingle/imagesingle';
	import windows from './window/window';
	import videos from './videos/videos';
	import articles from './article/article';
	import special from './special/special';
	import notice from './notice/notice';
	// import titles from './title/title';
	import coupon from './coupon/coupon';
	import richText from './richText/richText';
	import navBar from './navBar/navBar';
	import store from './store/store';
	import service from './service/service';
	import blank from './blank/blank';
	import guide from './guide/guide';
	import product from './product/product';
	import seckillProduct from './seckillProduct/seckillProduct';
	import assembleProduct from './assembleProduct/assembleProduct';
	import bargainProduct from './bargainProduct/bargainProduct';
	import live from './live/live';

	export default {
		components: {
			//search,
			banner,
			imagesingle,
			windows,
			videos,
			articles,
			special,
			notice,
			// titles,
			coupon,
			richText,
			navBar,
			store,
			service,
			blank,
			guide,
			product,
			seckillProduct,
			assembleProduct,
			bargainProduct,
			live
		},
		data() {
			return {
				sjlist: "",
				active1:0,
				select_indexdiy:60,
				page1:1,
				list_rows1:10,
				spfl:"",
				text:""
			}
		},
		methods: {
			/*获取数据*/
			getData() {
				let _this = this;
				_this._get('product.category/index', {}, function(res) {
					// _this.listData = res.data.list;
					// console.log('res.data.list', res.data.list[0].child);
					_this.sjlist = res.data.list[0].child

				});
			},
			// getIndexdata(){
			// 	let self = this;
			// 	self._get('index/index', {
			// 	}, function(res) {
			// 		self.text = res.data.setting.store.trends;
			// 	});
			// },
			clickname(item,index){
				console.log(item,index);
				this.active1 = index;
				let self=this;
				self.select_indexdiy = item;
					self._get('/product.product/lists', {
						category_id: item,
						list_rows: self.list_rows,
						page: self.page1,
						search: 0,
						sortPrice: 0,
						sortType: 'all',
					}, function(res) {
						// console.log("-------------------------",res.data.list)
						self.spfl = res.data.list;
						// console.log("-------------------------",self.spfl)
						});
			},
			clickname1(){
				let self=this;
					self._get('/product.product/lists', {
						category_id: 60,
						list_rows: 10,
						page: 1,
						search: 0,
						sortPrice: 0,
						sortType: 'all',
					}, function(res) {
						// console.log("-------------------------",res.data.list)
						self.spfl = res.data.list;
						// console.log("-------------------------",self.spfl)
						});
			}
		},
		props: ['diyItems','type','state'], // state : 取消展示
		created() {
			uni.$on('updatebg', function(data) {
				// console.log("走了updatebg111",data);
				// this.updatebgcl = data;
				uni.$emit('updatebg2', data);
			})
			// console.log(diyItems[0].type==='product'&&diyItems[0].data!=null);
			// console.log(this.diyItems[0],"测试");

			/*获取数据*/
			this.getData()
			// this.getIndexdata()
			this.clickname1()

		}
	}
</script>

<style lang="scss" scoped>
	.roll{
		display: flex;
		justify-content: center;
		align-items: center;
		.con1{
			font-weight: 700;
			font-size: 30rpx;
			width: 20%;
			.color1{
				color: #4D505A;
			}
			.color2{
				color: #F3AD4E;
			}
		}
		.con2{
			margin:0 10rpx;
			background-color: #D9D9D9;
			width: 1rpx;
			// height: 40rpx;
		}
		.con3{
			width: 70%;
		}
	}
	
	.navscroll {
		white-space: nowrap; // 设置内容不换行
		// height: 70rpx; // 设置滑动栏的高度

		// 通过渗透来消除状态栏下方的下划线
		/deep/ ::-webkit-scrollbar {
			width: 4px !important;
			height: 1px !important;
			overflow: auto !important;
			background: transparent !important;
			-webkit-appearance: auto !important;
			
		}

		.item {
			font-size: 25rpx; // 设置字体大小
			display: inline-block; // 设置为行内块
			line-height:68rpx; // 设置行高
			padding: 0 30rpx; // 设置外边距
			color: #333; // 设置颜色
			font-weight: 700;
			text-align: center;
		}
		.active{
			border-bottom:#FD2F2F 1rpx solid;
		}
	}
</style>
